<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
use app\admin\model\Goods as GoodsModel;

class Recycle extends Controller
{
    /**
     * 回收站显示列表
     *
     * @return \think\Response
     */
    public function index()
    {
        //
        $goods=Db::table('details')->order('shop_sort desc')->where('shop_del',0)->paginate(10);
        $this->assign('goods',$goods);
        return view();
    }

    /**
     * 商品的恢复
     */
    public function restore(){
        $de_id=input('param.de_id');
        $res= Db::table('details') ->where('de_id',$de_id)->setField('shop_del', 1);
        if ($res) {
            $this->success('商品恢复成功', 'index');
        } else {
            $this->error('商品恢复失败');
        }
    }
    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete()
    {
        $de_id=input('get.de_id');
        if(GoodsModel::destroy($de_id)){
            $this->success('商品已删除','index');
        }else{
            $this->error('删除失败');
        }

    }
}
